package com.klm.config;

import com.klm.client.TranslateClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author wq
 */
@Configuration
@ComponentScan(basePackages = {"com.klm"})
@EnableConfigurationProperties(TranslateApiProperties.class)
public class TranslateApiConfig {

    @Autowired
    private TranslateApiProperties properties;

    @Bean
    public TranslateClient translateClient() {
        return new TranslateClient(
            properties.getServer(),
            Integer.parseInt(properties.getPort()),
            properties.getAppKey(),
            properties.getAppSecret()
        );
    }
}


